package Command;

import Control.Controler;
import Control.ICommandExecutor;

public class Cd implements ICommandExecutor {
	private Cd(){}
	private static Cd instance;
	public static ICommandExecutor getInstance()
	{
		if (instance == null)
		{
			instance = new Cd();
		}
		return instance;
	}

	public void execute(String commandString) 
	{
		SetNewPath(commandString);
	}
	
	private void SetNewPath(String commandString)
	{
		String[] cmd = commandString.split(" ");
		if (cmd[1].length() == 1)
		{
			Controler.currentPath = cmd[1]+":\\";
		}
		else
		{
			Controler.currentPath +=cmd[1];
		}
	}
}
